3.5.29 \(\int (g+h x)^2 (a+b \log (c (d (e+f x)^p)^q))^2 \, dx\) [429]

3.5.29.1 Optimal result
3.5.29.2 Mathematica [A] (verified)
3.5.29.3 Rubi [A] (warning: unable to verify)
3.5.29.4 Maple [B] (verified)
3.5.29.5 Fricas [B] (verification not implemented)
3.5.29.6 Sympy [B] (verification not implemented)
3.5.29.7 Maxima [A] (verification not implemented)
3.5.29.8 Giac [B] (verification not implemented)
3.5.29.9 Mupad [B] (verification not implemented)

3.5.29.1 Optimal result

Integrand size = 28, antiderivative size = 323 \[ \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2 \, dx=\frac {2 b^2 (f g-e h)^2 p^2 q^2 x}{f^2}+\frac {b^2 h (f g-e h) p^2 q^2 (e+f x)^2}{2 f^3}+\frac {2 b^2 h^2 p^2 q^2 (e+f x)^3}{27 f^3}+\frac {b^2 (f g-e h)^3 p^2 q^2 \log ^2(e+f x)}{3 f^3 h}-\frac {2 b (f g-e h)^2 p q (e+f x) \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )}{f^3}-\frac {b h (f g-e h) p q (e+f x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )}{f^3}-\frac {2 b h^2 p q (e+f x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )}{9 f^3}-\frac {2 b (f g-e h)^3 p q \log (e+f x) \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )}{3 f^3 h}+\frac {(g+h x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2}{3 h} \]

output
2*b^2*(-e*h+f*g)^2*p^2*q^2*x/f^2+1/2*b^2*h*(-e*h+f*g)*p^2*q^2*(f*x+e)^2/f^ 
3+2/27*b^2*h^2*p^2*q^2*(f*x+e)^3/f^3+1/3*b^2*(-e*h+f*g)^3*p^2*q^2*ln(f*x+e 
)^2/f^3/h-2*b*(-e*h+f*g)^2*p*q*(f*x+e)*(a+b*ln(c*(d*(f*x+e)^p)^q))/f^3-b*h 
*(-e*h+f*g)*p*q*(f*x+e)^2*(a+b*ln(c*(d*(f*x+e)^p)^q))/f^3-2/9*b*h^2*p*q*(f 
*x+e)^3*(a+b*ln(c*(d*(f*x+e)^p)^q))/f^3-2/3*b*(-e*h+f*g)^3*p*q*ln(f*x+e)*( 
a+b*ln(c*(d*(f*x+e)^p)^q))/f^3/h+1/3*(h*x+g)^3*(a+b*ln(c*(d*(f*x+e)^p)^q)) 
^2/h
 
3.5.29.2 Mathematica [A] (verified)

Time = 0.11 (sec) , antiderivative size = 277, normalized size of antiderivative = 0.86 \[ \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2 \, dx=\frac {54 (f g-e h)^2 (e+f x) \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2+54 h (f g-e h) (e+f x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2+18 h^2 (e+f x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2-108 b (f g-e h)^2 p q \left (f (a-b p q) x+b (e+f x) \log \left (c \left (d (e+f x)^p\right )^q\right )\right )+27 b h (f g-e h) p q \left (b f p q x (2 e+f x)-2 (e+f x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )\right )+4 b h^2 p q \left (b f p q x \left (3 e^2+3 e f x+f^2 x^2\right )-3 (e+f x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )\right )}{54 f^3} \]

input
Integrate[(g + h*x)^2*(a + b*Log[c*(d*(e + f*x)^p)^q])^2,x]
 
output
(54*(f*g - e*h)^2*(e + f*x)*(a + b*Log[c*(d*(e + f*x)^p)^q])^2 + 54*h*(f*g 
 - e*h)*(e + f*x)^2*(a + b*Log[c*(d*(e + f*x)^p)^q])^2 + 18*h^2*(e + f*x)^ 
3*(a + b*Log[c*(d*(e + f*x)^p)^q])^2 - 108*b*(f*g - e*h)^2*p*q*(f*(a - b*p 
*q)*x + b*(e + f*x)*Log[c*(d*(e + f*x)^p)^q]) + 27*b*h*(f*g - e*h)*p*q*(b* 
f*p*q*x*(2*e + f*x) - 2*(e + f*x)^2*(a + b*Log[c*(d*(e + f*x)^p)^q])) + 4* 
b*h^2*p*q*(b*f*p*q*x*(3*e^2 + 3*e*f*x + f^2*x^2) - 3*(e + f*x)^3*(a + b*Lo 
g[c*(d*(e + f*x)^p)^q])))/(54*f^3)
 
3.5.29.3 Rubi [A] (warning: unable to verify)

Time = 1.00 (sec) , antiderivative size = 278, normalized size of antiderivative = 0.86, number of steps used = 7, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.214, Rules used = {2895, 2845, 2858, 27, 2772, 2009}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2 \, dx\)

\(\Big \downarrow \) 2895

\(\displaystyle \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2dx\)

\(\Big \downarrow \) 2845

\(\displaystyle \frac {(g+h x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2}{3 h}-\frac {2 b f p q \int \frac {(g+h x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )}{e+f x}dx}{3 h}\)

\(\Big \downarrow \) 2858

\(\displaystyle \frac {(g+h x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2}{3 h}-\frac {2 b p q \int \frac {\left (f \left (g-\frac {e h}{f}\right )+h (e+f x)\right )^3 \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )}{f^3 (e+f x)}d(e+f x)}{3 h}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {(g+h x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2}{3 h}-\frac {2 b p q \int \frac {(f g-e h+h (e+f x))^3 \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )}{e+f x}d(e+f x)}{3 f^3 h}\)

\(\Big \downarrow \) 2772

\(\displaystyle \frac {(g+h x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2}{3 h}-\frac {2 b p q \left (-b p q \int \left (\frac {1}{3} (e+f x)^2 h^3+\frac {3}{2} (f g-e h) (e+f x) h^2+3 (f g-e h)^2 h+\frac {(f g-e h)^3 \log (e+f x)}{e+f x}\right )d(e+f x)+\frac {3}{2} h^2 (e+f x)^2 (f g-e h) \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )+(f g-e h)^3 \log (e+f x) \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )+3 h (e+f x) (f g-e h)^2 \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )+\frac {1}{3} h^3 (e+f x)^3 \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )\right )}{3 f^3 h}\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {(g+h x)^3 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2}{3 h}-\frac {2 b p q \left (\frac {3}{2} h^2 (e+f x)^2 (f g-e h) \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )+(f g-e h)^3 \log (e+f x) \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )+3 h (e+f x) (f g-e h)^2 \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )+\frac {1}{3} h^3 (e+f x)^3 \left (a+b \log \left (c d^q (e+f x)^{p q}\right )\right )-b p q \left (\frac {3}{4} h^2 (e+f x)^2 (f g-e h)+3 h (e+f x) (f g-e h)^2+\frac {1}{2} (f g-e h)^3 \log ^2(e+f x)+\frac {1}{9} h^3 (e+f x)^3\right )\right )}{3 f^3 h}\)

input
Int[(g + h*x)^2*(a + b*Log[c*(d*(e + f*x)^p)^q])^2,x]
 
output
(-2*b*p*q*(-(b*p*q*(3*h*(f*g - e*h)^2*(e + f*x) + (3*h^2*(f*g - e*h)*(e + 
f*x)^2)/4 + (h^3*(e + f*x)^3)/9 + ((f*g - e*h)^3*Log[e + f*x]^2)/2)) + 3*h 
*(f*g - e*h)^2*(e + f*x)*(a + b*Log[c*d^q*(e + f*x)^(p*q)]) + (3*h^2*(f*g 
- e*h)*(e + f*x)^2*(a + b*Log[c*d^q*(e + f*x)^(p*q)]))/2 + (h^3*(e + f*x)^ 
3*(a + b*Log[c*d^q*(e + f*x)^(p*q)]))/3 + (f*g - e*h)^3*Log[e + f*x]*(a + 
b*Log[c*d^q*(e + f*x)^(p*q)])))/(3*f^3*h) + ((g + h*x)^3*(a + b*Log[c*(d*( 
e + f*x)^p)^q])^2)/(3*h)
 

3.5.29.3.1 Defintions of rubi rules used

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 2772
Int[((a_.) + Log[(c_.)*(x_)^(n_.)]*(b_.))*(x_)^(m_.)*((d_) + (e_.)*(x_)^(r_ 
.))^(q_.), x_Symbol] :> With[{u = IntHide[x^m*(d + e*x^r)^q, x]}, Simp[(a + 
 b*Log[c*x^n])   u, x] - Simp[b*n   Int[SimplifyIntegrand[u/x, x], x], x]] 
/; FreeQ[{a, b, c, d, e, n, r}, x] && IGtQ[q, 0] && IntegerQ[m] &&  !(EqQ[q 
, 1] && EqQ[m, -1])
 

rule 2845
Int[((a_.) + Log[(c_.)*((d_) + (e_.)*(x_))^(n_.)]*(b_.))^(p_)*((f_.) + (g_. 
)*(x_))^(q_.), x_Symbol] :> Simp[(f + g*x)^(q + 1)*((a + b*Log[c*(d + e*x)^ 
n])^p/(g*(q + 1))), x] - Simp[b*e*n*(p/(g*(q + 1)))   Int[(f + g*x)^(q + 1) 
*((a + b*Log[c*(d + e*x)^n])^(p - 1)/(d + e*x)), x], x] /; FreeQ[{a, b, c, 
d, e, f, g, n, q}, x] && NeQ[e*f - d*g, 0] && GtQ[p, 0] && NeQ[q, -1] && In 
tegersQ[2*p, 2*q] && ( !IGtQ[q, 0] || (EqQ[p, 2] && NeQ[q, 1]))
 

rule 2858
Int[((a_.) + Log[(c_.)*((d_) + (e_.)*(x_))^(n_.)]*(b_.))^(p_.)*((f_.) + (g_ 
.)*(x_))^(q_.)*((h_.) + (i_.)*(x_))^(r_.), x_Symbol] :> Simp[1/e   Subst[In 
t[(g*(x/e))^q*((e*h - d*i)/e + i*(x/e))^r*(a + b*Log[c*x^n])^p, x], x, d + 
e*x], x] /; FreeQ[{a, b, c, d, e, f, g, h, i, n, p, q, r}, x] && EqQ[e*f - 
d*g, 0] && (IGtQ[p, 0] || IGtQ[r, 0]) && IntegerQ[2*r]
 

rule 2895
Int[((a_.) + Log[(c_.)*((d_.)*((e_.) + (f_.)*(x_))^(m_.))^(n_)]*(b_.))^(p_. 
)*(u_.), x_Symbol] :> Subst[Int[u*(a + b*Log[c*d^n*(e + f*x)^(m*n)])^p, x], 
 c*d^n*(e + f*x)^(m*n), c*(d*(e + f*x)^m)^n] /; FreeQ[{a, b, c, d, e, f, m, 
 n, p}, x] &&  !IntegerQ[n] &&  !(EqQ[d, 1] && EqQ[m, 1]) && IntegralFreeQ[ 
IntHide[u*(a + b*Log[c*d^n*(e + f*x)^(m*n)])^p, x]]
 
3.5.29.4 Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(938\) vs. \(2(311)=622\).

Time = 5.68 (sec) , antiderivative size = 939, normalized size of antiderivative = 2.91

method result size
parallelrisch \(\frac {162 \ln \left (f x +e \right ) b^{2} e^{3} f g h \,p^{2} q^{2}+108 x a b \,e^{2} f^{2} g h p q -108 \ln \left (f x +e \right ) a b \,e^{3} f g h p q +108 x \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) a b e \,f^{3} g^{2}-108 \ln \left (f x +e \right ) b^{2} e^{2} f^{2} g^{2} p^{2} q^{2}+36 \ln \left (f x +e \right ) a b \,e^{4} h^{2} p q +4 x^{3} b^{2} e \,f^{3} h^{2} p^{2} q^{2}-15 x^{2} b^{2} e^{2} f^{2} h^{2} p^{2} q^{2}+66 x \,b^{2} e^{3} f \,h^{2} p^{2} q^{2}+108 x \,b^{2} e \,f^{3} g^{2} p^{2} q^{2}+36 x^{3} \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) a b e \,f^{3} h^{2}+54 x^{2} {\ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right )}^{2} b^{2} e \,f^{3} g h +108 \ln \left (f x +e \right ) a b \,e^{2} f^{2} g^{2} p q -12 x^{3} \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) b^{2} e \,f^{3} h^{2} p q +27 x^{2} b^{2} e \,f^{3} g h \,p^{2} q^{2}-12 x^{3} a b e \,f^{3} h^{2} p q +18 x^{2} \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) b^{2} e^{2} f^{2} h^{2} p q -108 a b \,e^{3} f g h p q -54 x^{2} \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) b^{2} e \,f^{3} g h p q -54 x^{2} a b e \,f^{3} g h p q +108 x \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) b^{2} e^{2} f^{2} g h p q -162 x \,b^{2} e^{2} f^{2} g h \,p^{2} q^{2}+18 x^{2} a b \,e^{2} f^{2} h^{2} p q -36 x \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) b^{2} e^{3} f \,h^{2} p q -108 x \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) b^{2} e \,f^{3} g^{2} p q +108 x^{2} \ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right ) a b e \,f^{3} g h -36 x a b \,e^{3} f \,h^{2} p q -108 x a b e \,f^{3} g^{2} p q -108 b^{2} e^{2} f^{2} g^{2} p^{2} q^{2}+36 a b \,e^{4} h^{2} p q +54 x \,a^{2} e \,f^{3} g^{2}+18 x^{3} a^{2} e \,f^{3} h^{2}+54 {\ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right )}^{2} b^{2} e^{2} f^{2} g^{2}+108 a b \,e^{2} f^{2} g^{2} p q +18 x^{3} {\ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right )}^{2} b^{2} e \,f^{3} h^{2}+54 x {\ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right )}^{2} b^{2} e \,f^{3} g^{2}+54 x^{2} a^{2} e \,f^{3} g h -54 {\ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right )}^{2} b^{2} e^{3} f g h -66 \ln \left (f x +e \right ) b^{2} e^{4} h^{2} p^{2} q^{2}-66 b^{2} e^{4} h^{2} p^{2} q^{2}+162 b^{2} e^{3} f g h \,p^{2} q^{2}-54 a^{2} e^{2} f^{2} g^{2}+18 {\ln \left (c \left (d \left (f x +e \right )^{p}\right )^{q}\right )}^{2} b^{2} e^{4} h^{2}}{54 e \,f^{3}}\) \(939\)

input
int((h*x+g)^2*(a+b*ln(c*(d*(f*x+e)^p)^q))^2,x,method=_RETURNVERBOSE)
 
output
1/54*(162*ln(f*x+e)*b^2*e^3*f*g*h*p^2*q^2+108*x*a*b*e^2*f^2*g*h*p*q-108*ln 
(f*x+e)*a*b*e^3*f*g*h*p*q+108*x*ln(c*(d*(f*x+e)^p)^q)*a*b*e*f^3*g^2-108*ln 
(f*x+e)*b^2*e^2*f^2*g^2*p^2*q^2+36*ln(f*x+e)*a*b*e^4*h^2*p*q+4*x^3*b^2*e*f 
^3*h^2*p^2*q^2-15*x^2*b^2*e^2*f^2*h^2*p^2*q^2+66*x*b^2*e^3*f*h^2*p^2*q^2+1 
08*x*b^2*e*f^3*g^2*p^2*q^2+36*x^3*ln(c*(d*(f*x+e)^p)^q)*a*b*e*f^3*h^2+54*x 
^2*ln(c*(d*(f*x+e)^p)^q)^2*b^2*e*f^3*g*h+108*ln(f*x+e)*a*b*e^2*f^2*g^2*p*q 
-12*x^3*ln(c*(d*(f*x+e)^p)^q)*b^2*e*f^3*h^2*p*q+27*x^2*b^2*e*f^3*g*h*p^2*q 
^2-12*x^3*a*b*e*f^3*h^2*p*q+18*x^2*ln(c*(d*(f*x+e)^p)^q)*b^2*e^2*f^2*h^2*p 
*q-108*a*b*e^3*f*g*h*p*q-54*x^2*ln(c*(d*(f*x+e)^p)^q)*b^2*e*f^3*g*h*p*q-54 
*x^2*a*b*e*f^3*g*h*p*q+108*x*ln(c*(d*(f*x+e)^p)^q)*b^2*e^2*f^2*g*h*p*q-162 
*x*b^2*e^2*f^2*g*h*p^2*q^2+18*x^2*a*b*e^2*f^2*h^2*p*q-36*x*ln(c*(d*(f*x+e) 
^p)^q)*b^2*e^3*f*h^2*p*q-108*x*ln(c*(d*(f*x+e)^p)^q)*b^2*e*f^3*g^2*p*q+108 
*x^2*ln(c*(d*(f*x+e)^p)^q)*a*b*e*f^3*g*h-36*x*a*b*e^3*f*h^2*p*q-108*x*a*b* 
e*f^3*g^2*p*q-108*b^2*e^2*f^2*g^2*p^2*q^2+36*a*b*e^4*h^2*p*q+54*x*a^2*e*f^ 
3*g^2+18*x^3*a^2*e*f^3*h^2+54*ln(c*(d*(f*x+e)^p)^q)^2*b^2*e^2*f^2*g^2+108* 
a*b*e^2*f^2*g^2*p*q+18*x^3*ln(c*(d*(f*x+e)^p)^q)^2*b^2*e*f^3*h^2+54*x*ln(c 
*(d*(f*x+e)^p)^q)^2*b^2*e*f^3*g^2+54*x^2*a^2*e*f^3*g*h-54*ln(c*(d*(f*x+e)^ 
p)^q)^2*b^2*e^3*f*g*h-66*ln(f*x+e)*b^2*e^4*h^2*p^2*q^2-66*b^2*e^4*h^2*p^2* 
q^2+162*b^2*e^3*f*g*h*p^2*q^2-54*a^2*e^2*f^2*g^2+18*ln(c*(d*(f*x+e)^p)^q)^ 
2*b^2*e^4*h^2)/e/f^3
 
3.5.29.5 Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 1137 vs. \(2 (311) = 622\).

Time = 0.34 (sec) , antiderivative size = 1137, normalized size of antiderivative = 3.52 \[ \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2 \, dx=\text {Too large to display} \]

input
integrate((h*x+g)^2*(a+b*log(c*(d*(f*x+e)^p)^q))^2,x, algorithm="fricas")
 
output
1/54*(2*(2*b^2*f^3*h^2*p^2*q^2 - 6*a*b*f^3*h^2*p*q + 9*a^2*f^3*h^2)*x^3 + 
3*(18*a^2*f^3*g*h + (9*b^2*f^3*g*h - 5*b^2*e*f^2*h^2)*p^2*q^2 - 6*(3*a*b*f 
^3*g*h - a*b*e*f^2*h^2)*p*q)*x^2 + 18*(b^2*f^3*h^2*p^2*q^2*x^3 + 3*b^2*f^3 
*g*h*p^2*q^2*x^2 + 3*b^2*f^3*g^2*p^2*q^2*x + (3*b^2*e*f^2*g^2 - 3*b^2*e^2* 
f*g*h + b^2*e^3*h^2)*p^2*q^2)*log(f*x + e)^2 + 18*(b^2*f^3*h^2*x^3 + 3*b^2 
*f^3*g*h*x^2 + 3*b^2*f^3*g^2*x)*log(c)^2 + 18*(b^2*f^3*h^2*q^2*x^3 + 3*b^2 
*f^3*g*h*q^2*x^2 + 3*b^2*f^3*g^2*q^2*x)*log(d)^2 + 6*(9*a^2*f^3*g^2 + (18* 
b^2*f^3*g^2 - 27*b^2*e*f^2*g*h + 11*b^2*e^2*f*h^2)*p^2*q^2 - 6*(3*a*b*f^3* 
g^2 - 3*a*b*e*f^2*g*h + a*b*e^2*f*h^2)*p*q)*x - 6*((18*b^2*e*f^2*g^2 - 27* 
b^2*e^2*f*g*h + 11*b^2*e^3*h^2)*p^2*q^2 + 2*(b^2*f^3*h^2*p^2*q^2 - 3*a*b*f 
^3*h^2*p*q)*x^3 - 6*(3*a*b*e*f^2*g^2 - 3*a*b*e^2*f*g*h + a*b*e^3*h^2)*p*q 
- 3*(6*a*b*f^3*g*h*p*q - (3*b^2*f^3*g*h - b^2*e*f^2*h^2)*p^2*q^2)*x^2 - 6* 
(3*a*b*f^3*g^2*p*q - (3*b^2*f^3*g^2 - 3*b^2*e*f^2*g*h + b^2*e^2*f*h^2)*p^2 
*q^2)*x - 6*(b^2*f^3*h^2*p*q*x^3 + 3*b^2*f^3*g*h*p*q*x^2 + 3*b^2*f^3*g^2*p 
*q*x + (3*b^2*e*f^2*g^2 - 3*b^2*e^2*f*g*h + b^2*e^3*h^2)*p*q)*log(c) - 6*( 
b^2*f^3*h^2*p*q^2*x^3 + 3*b^2*f^3*g*h*p*q^2*x^2 + 3*b^2*f^3*g^2*p*q^2*x + 
(3*b^2*e*f^2*g^2 - 3*b^2*e^2*f*g*h + b^2*e^3*h^2)*p*q^2)*log(d))*log(f*x + 
 e) - 6*(2*(b^2*f^3*h^2*p*q - 3*a*b*f^3*h^2)*x^3 - 3*(6*a*b*f^3*g*h - (3*b 
^2*f^3*g*h - b^2*e*f^2*h^2)*p*q)*x^2 - 6*(3*a*b*f^3*g^2 - (3*b^2*f^3*g^2 - 
 3*b^2*e*f^2*g*h + b^2*e^2*f*h^2)*p*q)*x)*log(c) - 6*(2*(b^2*f^3*h^2*p*...
 
3.5.29.6 Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 894 vs. \(2 (311) = 622\).

Time = 2.59 (sec) , antiderivative size = 894, normalized size of antiderivative = 2.77 \[ \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2 \, dx=\begin {cases} a^{2} g^{2} x + a^{2} g h x^{2} + \frac {a^{2} h^{2} x^{3}}{3} + \frac {2 a b e^{3} h^{2} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{3 f^{3}} - \frac {2 a b e^{2} g h \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{f^{2}} - \frac {2 a b e^{2} h^{2} p q x}{3 f^{2}} + \frac {2 a b e g^{2} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{f} + \frac {2 a b e g h p q x}{f} + \frac {a b e h^{2} p q x^{2}}{3 f} - 2 a b g^{2} p q x + 2 a b g^{2} x \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )} - a b g h p q x^{2} + 2 a b g h x^{2} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )} - \frac {2 a b h^{2} p q x^{3}}{9} + \frac {2 a b h^{2} x^{3} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{3} - \frac {11 b^{2} e^{3} h^{2} p q \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{9 f^{3}} + \frac {b^{2} e^{3} h^{2} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}^{2}}{3 f^{3}} + \frac {3 b^{2} e^{2} g h p q \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{f^{2}} - \frac {b^{2} e^{2} g h \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}^{2}}{f^{2}} + \frac {11 b^{2} e^{2} h^{2} p^{2} q^{2} x}{9 f^{2}} - \frac {2 b^{2} e^{2} h^{2} p q x \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{3 f^{2}} - \frac {2 b^{2} e g^{2} p q \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{f} + \frac {b^{2} e g^{2} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}^{2}}{f} - \frac {3 b^{2} e g h p^{2} q^{2} x}{f} + \frac {2 b^{2} e g h p q x \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{f} - \frac {5 b^{2} e h^{2} p^{2} q^{2} x^{2}}{18 f} + \frac {b^{2} e h^{2} p q x^{2} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{3 f} + 2 b^{2} g^{2} p^{2} q^{2} x - 2 b^{2} g^{2} p q x \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )} + b^{2} g^{2} x \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}^{2} + \frac {b^{2} g h p^{2} q^{2} x^{2}}{2} - b^{2} g h p q x^{2} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )} + b^{2} g h x^{2} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}^{2} + \frac {2 b^{2} h^{2} p^{2} q^{2} x^{3}}{27} - \frac {2 b^{2} h^{2} p q x^{3} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}}{9} + \frac {b^{2} h^{2} x^{3} \log {\left (c \left (d \left (e + f x\right )^{p}\right )^{q} \right )}^{2}}{3} & \text {for}\: f \neq 0 \\\left (a + b \log {\left (c \left (d e^{p}\right )^{q} \right )}\right )^{2} \left (g^{2} x + g h x^{2} + \frac {h^{2} x^{3}}{3}\right ) & \text {otherwise} \end {cases} \]

input
integrate((h*x+g)**2*(a+b*ln(c*(d*(f*x+e)**p)**q))**2,x)
 
output
Piecewise((a**2*g**2*x + a**2*g*h*x**2 + a**2*h**2*x**3/3 + 2*a*b*e**3*h** 
2*log(c*(d*(e + f*x)**p)**q)/(3*f**3) - 2*a*b*e**2*g*h*log(c*(d*(e + f*x)* 
*p)**q)/f**2 - 2*a*b*e**2*h**2*p*q*x/(3*f**2) + 2*a*b*e*g**2*log(c*(d*(e + 
 f*x)**p)**q)/f + 2*a*b*e*g*h*p*q*x/f + a*b*e*h**2*p*q*x**2/(3*f) - 2*a*b* 
g**2*p*q*x + 2*a*b*g**2*x*log(c*(d*(e + f*x)**p)**q) - a*b*g*h*p*q*x**2 + 
2*a*b*g*h*x**2*log(c*(d*(e + f*x)**p)**q) - 2*a*b*h**2*p*q*x**3/9 + 2*a*b* 
h**2*x**3*log(c*(d*(e + f*x)**p)**q)/3 - 11*b**2*e**3*h**2*p*q*log(c*(d*(e 
 + f*x)**p)**q)/(9*f**3) + b**2*e**3*h**2*log(c*(d*(e + f*x)**p)**q)**2/(3 
*f**3) + 3*b**2*e**2*g*h*p*q*log(c*(d*(e + f*x)**p)**q)/f**2 - b**2*e**2*g 
*h*log(c*(d*(e + f*x)**p)**q)**2/f**2 + 11*b**2*e**2*h**2*p**2*q**2*x/(9*f 
**2) - 2*b**2*e**2*h**2*p*q*x*log(c*(d*(e + f*x)**p)**q)/(3*f**2) - 2*b**2 
*e*g**2*p*q*log(c*(d*(e + f*x)**p)**q)/f + b**2*e*g**2*log(c*(d*(e + f*x)* 
*p)**q)**2/f - 3*b**2*e*g*h*p**2*q**2*x/f + 2*b**2*e*g*h*p*q*x*log(c*(d*(e 
 + f*x)**p)**q)/f - 5*b**2*e*h**2*p**2*q**2*x**2/(18*f) + b**2*e*h**2*p*q* 
x**2*log(c*(d*(e + f*x)**p)**q)/(3*f) + 2*b**2*g**2*p**2*q**2*x - 2*b**2*g 
**2*p*q*x*log(c*(d*(e + f*x)**p)**q) + b**2*g**2*x*log(c*(d*(e + f*x)**p)* 
*q)**2 + b**2*g*h*p**2*q**2*x**2/2 - b**2*g*h*p*q*x**2*log(c*(d*(e + f*x)* 
*p)**q) + b**2*g*h*x**2*log(c*(d*(e + f*x)**p)**q)**2 + 2*b**2*h**2*p**2*q 
**2*x**3/27 - 2*b**2*h**2*p*q*x**3*log(c*(d*(e + f*x)**p)**q)/9 + b**2*h** 
2*x**3*log(c*(d*(e + f*x)**p)**q)**2/3, Ne(f, 0)), ((a + b*log(c*(d*e**...
 
3.5.29.7 Maxima [A] (verification not implemented)

Time = 0.22 (sec) , antiderivative size = 605, normalized size of antiderivative = 1.87 \[ \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2 \, dx=\frac {1}{3} \, b^{2} h^{2} x^{3} \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right )^{2} - 2 \, a b f g^{2} p q {\left (\frac {x}{f} - \frac {e \log \left (f x + e\right )}{f^{2}}\right )} + \frac {1}{9} \, a b f h^{2} p q {\left (\frac {6 \, e^{3} \log \left (f x + e\right )}{f^{4}} - \frac {2 \, f^{2} x^{3} - 3 \, e f x^{2} + 6 \, e^{2} x}{f^{3}}\right )} - a b f g h p q {\left (\frac {2 \, e^{2} \log \left (f x + e\right )}{f^{3}} + \frac {f x^{2} - 2 \, e x}{f^{2}}\right )} + \frac {2}{3} \, a b h^{2} x^{3} \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right ) + b^{2} g h x^{2} \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right )^{2} + \frac {1}{3} \, a^{2} h^{2} x^{3} + 2 \, a b g h x^{2} \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right ) + b^{2} g^{2} x \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right )^{2} + a^{2} g h x^{2} + 2 \, a b g^{2} x \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right ) - {\left (2 \, f p q {\left (\frac {x}{f} - \frac {e \log \left (f x + e\right )}{f^{2}}\right )} \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right ) + \frac {{\left (e \log \left (f x + e\right )^{2} - 2 \, f x + 2 \, e \log \left (f x + e\right )\right )} p^{2} q^{2}}{f}\right )} b^{2} g^{2} - \frac {1}{2} \, {\left (2 \, f p q {\left (\frac {2 \, e^{2} \log \left (f x + e\right )}{f^{3}} + \frac {f x^{2} - 2 \, e x}{f^{2}}\right )} \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right ) - \frac {{\left (f^{2} x^{2} + 2 \, e^{2} \log \left (f x + e\right )^{2} - 6 \, e f x + 6 \, e^{2} \log \left (f x + e\right )\right )} p^{2} q^{2}}{f^{2}}\right )} b^{2} g h + \frac {1}{54} \, {\left (6 \, f p q {\left (\frac {6 \, e^{3} \log \left (f x + e\right )}{f^{4}} - \frac {2 \, f^{2} x^{3} - 3 \, e f x^{2} + 6 \, e^{2} x}{f^{3}}\right )} \log \left (\left ({\left (f x + e\right )}^{p} d\right )^{q} c\right ) + \frac {{\left (4 \, f^{3} x^{3} - 15 \, e f^{2} x^{2} - 18 \, e^{3} \log \left (f x + e\right )^{2} + 66 \, e^{2} f x - 66 \, e^{3} \log \left (f x + e\right )\right )} p^{2} q^{2}}{f^{3}}\right )} b^{2} h^{2} + a^{2} g^{2} x \]

input
integrate((h*x+g)^2*(a+b*log(c*(d*(f*x+e)^p)^q))^2,x, algorithm="maxima")
 
output
1/3*b^2*h^2*x^3*log(((f*x + e)^p*d)^q*c)^2 - 2*a*b*f*g^2*p*q*(x/f - e*log( 
f*x + e)/f^2) + 1/9*a*b*f*h^2*p*q*(6*e^3*log(f*x + e)/f^4 - (2*f^2*x^3 - 3 
*e*f*x^2 + 6*e^2*x)/f^3) - a*b*f*g*h*p*q*(2*e^2*log(f*x + e)/f^3 + (f*x^2 
- 2*e*x)/f^2) + 2/3*a*b*h^2*x^3*log(((f*x + e)^p*d)^q*c) + b^2*g*h*x^2*log 
(((f*x + e)^p*d)^q*c)^2 + 1/3*a^2*h^2*x^3 + 2*a*b*g*h*x^2*log(((f*x + e)^p 
*d)^q*c) + b^2*g^2*x*log(((f*x + e)^p*d)^q*c)^2 + a^2*g*h*x^2 + 2*a*b*g^2* 
x*log(((f*x + e)^p*d)^q*c) - (2*f*p*q*(x/f - e*log(f*x + e)/f^2)*log(((f*x 
 + e)^p*d)^q*c) + (e*log(f*x + e)^2 - 2*f*x + 2*e*log(f*x + e))*p^2*q^2/f) 
*b^2*g^2 - 1/2*(2*f*p*q*(2*e^2*log(f*x + e)/f^3 + (f*x^2 - 2*e*x)/f^2)*log 
(((f*x + e)^p*d)^q*c) - (f^2*x^2 + 2*e^2*log(f*x + e)^2 - 6*e*f*x + 6*e^2* 
log(f*x + e))*p^2*q^2/f^2)*b^2*g*h + 1/54*(6*f*p*q*(6*e^3*log(f*x + e)/f^4 
 - (2*f^2*x^3 - 3*e*f*x^2 + 6*e^2*x)/f^3)*log(((f*x + e)^p*d)^q*c) + (4*f^ 
3*x^3 - 15*e*f^2*x^2 - 18*e^3*log(f*x + e)^2 + 66*e^2*f*x - 66*e^3*log(f*x 
 + e))*p^2*q^2/f^3)*b^2*h^2 + a^2*g^2*x
 
3.5.29.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 2106 vs. \(2 (311) = 622\).

Time = 0.34 (sec) , antiderivative size = 2106, normalized size of antiderivative = 6.52 \[ \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2 \, dx=\text {Too large to display} \]

input
integrate((h*x+g)^2*(a+b*log(c*(d*(f*x+e)^p)^q))^2,x, algorithm="giac")
 
output
(f*x + e)*b^2*g^2*p^2*q^2*log(f*x + e)^2/f + (f*x + e)^2*b^2*g*h*p^2*q^2*l 
og(f*x + e)^2/f^2 - 2*(f*x + e)*b^2*e*g*h*p^2*q^2*log(f*x + e)^2/f^2 + 1/3 
*(f*x + e)^3*b^2*h^2*p^2*q^2*log(f*x + e)^2/f^3 - (f*x + e)^2*b^2*e*h^2*p^ 
2*q^2*log(f*x + e)^2/f^3 + (f*x + e)*b^2*e^2*h^2*p^2*q^2*log(f*x + e)^2/f^ 
3 - 2*(f*x + e)*b^2*g^2*p^2*q^2*log(f*x + e)/f - (f*x + e)^2*b^2*g*h*p^2*q 
^2*log(f*x + e)/f^2 + 4*(f*x + e)*b^2*e*g*h*p^2*q^2*log(f*x + e)/f^2 - 2/9 
*(f*x + e)^3*b^2*h^2*p^2*q^2*log(f*x + e)/f^3 + (f*x + e)^2*b^2*e*h^2*p^2* 
q^2*log(f*x + e)/f^3 - 2*(f*x + e)*b^2*e^2*h^2*p^2*q^2*log(f*x + e)/f^3 + 
2*(f*x + e)*b^2*g^2*p*q^2*log(f*x + e)*log(d)/f + 2*(f*x + e)^2*b^2*g*h*p* 
q^2*log(f*x + e)*log(d)/f^2 - 4*(f*x + e)*b^2*e*g*h*p*q^2*log(f*x + e)*log 
(d)/f^2 + 2/3*(f*x + e)^3*b^2*h^2*p*q^2*log(f*x + e)*log(d)/f^3 - 2*(f*x + 
 e)^2*b^2*e*h^2*p*q^2*log(f*x + e)*log(d)/f^3 + 2*(f*x + e)*b^2*e^2*h^2*p* 
q^2*log(f*x + e)*log(d)/f^3 + 2*(f*x + e)*b^2*g^2*p^2*q^2/f + 1/2*(f*x + e 
)^2*b^2*g*h*p^2*q^2/f^2 - 4*(f*x + e)*b^2*e*g*h*p^2*q^2/f^2 + 2/27*(f*x + 
e)^3*b^2*h^2*p^2*q^2/f^3 - 1/2*(f*x + e)^2*b^2*e*h^2*p^2*q^2/f^3 + 2*(f*x 
+ e)*b^2*e^2*h^2*p^2*q^2/f^3 + 2*(f*x + e)*b^2*g^2*p*q*log(f*x + e)*log(c) 
/f + 2*(f*x + e)^2*b^2*g*h*p*q*log(f*x + e)*log(c)/f^2 - 4*(f*x + e)*b^2*e 
*g*h*p*q*log(f*x + e)*log(c)/f^2 + 2/3*(f*x + e)^3*b^2*h^2*p*q*log(f*x + e 
)*log(c)/f^3 - 2*(f*x + e)^2*b^2*e*h^2*p*q*log(f*x + e)*log(c)/f^3 + 2*(f* 
x + e)*b^2*e^2*h^2*p*q*log(f*x + e)*log(c)/f^3 - 2*(f*x + e)*b^2*g^2*p*...
 
3.5.29.9 Mupad [B] (verification not implemented)

Time = 1.74 (sec) , antiderivative size = 652, normalized size of antiderivative = 2.02 \[ \int (g+h x)^2 \left (a+b \log \left (c \left (d (e+f x)^p\right )^q\right )\right )^2 \, dx={\ln \left (c\,{\left (d\,{\left (e+f\,x\right )}^p\right )}^q\right )}^2\,\left (b^2\,g^2\,x+\frac {b^2\,h^2\,x^3}{3}+\frac {e\,\left (b^2\,e^2\,h^2-3\,b^2\,e\,f\,g\,h+3\,b^2\,f^2\,g^2\right )}{3\,f^3}+b^2\,g\,h\,x^2\right )+\ln \left (c\,{\left (d\,{\left (e+f\,x\right )}^p\right )}^q\right )\,\left (\frac {x^2\,\left (\frac {3\,b\,h\,\left (a\,e\,h+2\,a\,f\,g-b\,f\,g\,p\,q\right )}{f}-\frac {b\,e\,h^2\,\left (3\,a-b\,p\,q\right )}{f}\right )}{3}-\frac {x\,\left (\frac {e\,\left (\frac {6\,b\,h\,\left (a\,e\,h+2\,a\,f\,g-b\,f\,g\,p\,q\right )}{f}-\frac {2\,b\,e\,h^2\,\left (3\,a-b\,p\,q\right )}{f}\right )}{f}-\frac {6\,b\,g\,\left (2\,a\,e\,h+a\,f\,g-b\,f\,g\,p\,q\right )}{f}\right )}{3}+\frac {2\,b\,h^2\,x^3\,\left (3\,a-b\,p\,q\right )}{9}\right )+x\,\left (\frac {18\,a^2\,e\,f\,g\,h+9\,a^2\,f^2\,g^2-18\,a\,b\,f^2\,g^2\,p\,q+6\,b^2\,e^2\,h^2\,p^2\,q^2-18\,b^2\,e\,f\,g\,h\,p^2\,q^2+18\,b^2\,f^2\,g^2\,p^2\,q^2}{9\,f^2}-\frac {e\,\left (\frac {h\,\left (3\,a^2\,e\,h+6\,a^2\,f\,g-b^2\,e\,h\,p^2\,q^2+3\,b^2\,f\,g\,p^2\,q^2-6\,a\,b\,f\,g\,p\,q\right )}{3\,f}-\frac {e\,h^2\,\left (9\,a^2-6\,a\,b\,p\,q+2\,b^2\,p^2\,q^2\right )}{9\,f}\right )}{f}\right )+x^2\,\left (\frac {h\,\left (3\,a^2\,e\,h+6\,a^2\,f\,g-b^2\,e\,h\,p^2\,q^2+3\,b^2\,f\,g\,p^2\,q^2-6\,a\,b\,f\,g\,p\,q\right )}{6\,f}-\frac {e\,h^2\,\left (9\,a^2-6\,a\,b\,p\,q+2\,b^2\,p^2\,q^2\right )}{18\,f}\right )-\frac {\ln \left (e+f\,x\right )\,\left (11\,b^2\,e^3\,h^2\,p^2\,q^2-27\,b^2\,e^2\,f\,g\,h\,p^2\,q^2+18\,b^2\,e\,f^2\,g^2\,p^2\,q^2-6\,a\,b\,e^3\,h^2\,p\,q+18\,a\,b\,e^2\,f\,g\,h\,p\,q-18\,a\,b\,e\,f^2\,g^2\,p\,q\right )}{9\,f^3}+\frac {h^2\,x^3\,\left (9\,a^2-6\,a\,b\,p\,q+2\,b^2\,p^2\,q^2\right )}{27} \]

input
int((g + h*x)^2*(a + b*log(c*(d*(e + f*x)^p)^q))^2,x)
 
output
log(c*(d*(e + f*x)^p)^q)^2*(b^2*g^2*x + (b^2*h^2*x^3)/3 + (e*(b^2*e^2*h^2 
+ 3*b^2*f^2*g^2 - 3*b^2*e*f*g*h))/(3*f^3) + b^2*g*h*x^2) + log(c*(d*(e + f 
*x)^p)^q)*((x^2*((3*b*h*(a*e*h + 2*a*f*g - b*f*g*p*q))/f - (b*e*h^2*(3*a - 
 b*p*q))/f))/3 - (x*((e*((6*b*h*(a*e*h + 2*a*f*g - b*f*g*p*q))/f - (2*b*e* 
h^2*(3*a - b*p*q))/f))/f - (6*b*g*(2*a*e*h + a*f*g - b*f*g*p*q))/f))/3 + ( 
2*b*h^2*x^3*(3*a - b*p*q))/9) + x*((9*a^2*f^2*g^2 + 6*b^2*e^2*h^2*p^2*q^2 
+ 18*b^2*f^2*g^2*p^2*q^2 + 18*a^2*e*f*g*h - 18*a*b*f^2*g^2*p*q - 18*b^2*e* 
f*g*h*p^2*q^2)/(9*f^2) - (e*((h*(3*a^2*e*h + 6*a^2*f*g - b^2*e*h*p^2*q^2 + 
 3*b^2*f*g*p^2*q^2 - 6*a*b*f*g*p*q))/(3*f) - (e*h^2*(9*a^2 + 2*b^2*p^2*q^2 
 - 6*a*b*p*q))/(9*f)))/f) + x^2*((h*(3*a^2*e*h + 6*a^2*f*g - b^2*e*h*p^2*q 
^2 + 3*b^2*f*g*p^2*q^2 - 6*a*b*f*g*p*q))/(6*f) - (e*h^2*(9*a^2 + 2*b^2*p^2 
*q^2 - 6*a*b*p*q))/(18*f)) - (log(e + f*x)*(11*b^2*e^3*h^2*p^2*q^2 - 6*a*b 
*e^3*h^2*p*q + 18*b^2*e*f^2*g^2*p^2*q^2 - 27*b^2*e^2*f*g*h*p^2*q^2 - 18*a* 
b*e*f^2*g^2*p*q + 18*a*b*e^2*f*g*h*p*q))/(9*f^3) + (h^2*x^3*(9*a^2 + 2*b^2 
*p^2*q^2 - 6*a*b*p*q))/27